<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text">
<!--设置触发事件-->
<input type="button" value="按钮" onclick="f()">
<div>div</div>
<script>
    function f(){
        //获取的是第一个input
        let i = document.querySelector("input");

        let d = document.querySelector("div");
        //把文本框的内容赋给div
        d.innerText = i.value;
    }
</script>
</body>
</html>